package com.itcam.lambda.pro02lambda;

import com.itcam.lambda.pro02lambda.interface_.IGreeting;
import com.itcam.lambda.pro02lambda.interface_.IMathOperation;

/**
 * @author : Cammy.Wu
 * Description : 
 */

public class LambdaSyntaxTest {

    public static void main(String[] args) {
        // 0.lambda表达式的基本格式
        IMathOperation mo0 = (int a, int b) -> {
            return a + b;
        };
        System.out.println(mo0.operation(1, 2));

        // 1.省略大括号
        IGreeting greeting = (String msg) -> System.out.println("Hello" + msg);
        greeting.sayHello("Hello Lambda");

        // 2.省略小括号
        greeting = msg -> System.out.println("Hello" + msg);
        greeting.sayHello("Hello Lambda");

        // 3，省略return
        IMathOperation mo1 = (int a, int b) -> a * b;
        System.out.println(mo1.operation(5, 5));

        // 4.省略参数类型和大括号
        IMathOperation mo2 = (a, b) -> a / b;
        System.out.println(mo2.operation(5, 5));
    }
}
